from sqlalchemy import Column, DateTime, Integer, String, Date, Time
from sqlalchemy.dialects.mysql import DECIMAL

from config.database import Base


class KylinTrade(Base):
    """
    总交易流水表
    """

    __tablename__ = 'kylin_trade'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='总交易流水id')
    name = Column(String(50), nullable=False, comment='策略名称')
    trade_id = Column(Integer, nullable=False, comment='策略交易流水id')
    date = Column(Date, nullable=True, comment='交易日期')
    time = Column(Time, nullable=True, comment='交易时间')
    price = Column(DECIMAL(10, 4), nullable=True, comment='交易价格')
    direction = Column(String(10), nullable=True, comment='交易方向')
    offset = Column(String(10), nullable=True, comment='开平标志')
    volume = Column(Integer, nullable=True, default=None, comment='交易量')
    pos = Column(Integer, nullable=True, default=None, comment='交易后持仓')
